home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / objectex / ex29.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  843 b   |  33 lines

  1. Program ex29;
  2.  
  3. {
  4.  Program to demonstrate the TCollection.DeleteAll method 
  5.  Compare with example 28, where FreeAll is used.
  6. }
  7.  
  8. Uses Objects,MyObject; { For TMyObject definition and registration }
  9.  
  10. Var C : PCollection;
  11.     M : PMyObject;
  12.     I,InitMem : Longint;
  13.  
  14. begin
  15.   Randomize;
  16.   C:=New(PCollection,Init(120,10));
  17.   InitMem:=Memavail;
  18.   Writeln ('Initial memory : ',InitMem);
  19.   For I:=1 to 100 do
  20.     begin
  21.     M:=New(PMyObject,Init);
  22.     M^.SetField(I-1);
  23.     C^.Insert(M);
  24.     end;
  25.   Writeln ('Added 100 Items. Memory available : ',Memavail);
  26.   Write ('Lost : ',Initmem-Memavail,' bytes.');
  27.   Write   ('(Should be 100*',SizeOF(TMyObject));
  28.   Writeln ('=',100*SizeOf(TMyObject),')');
  29.   C^.DeleteAll;
  30.   Writeln ('Deleted all objects. Memory available : ',Memavail);
  31.   Writeln ('Lost : ',Initmem-Memavail,' bytes.');
  32.   Dispose(C,Done);
  33. end.